<template>
  <div class="pageContainer">
    <div class="search">
      <van-search v-model="searchValue" placeholder="请输入搜索关键词"></van-search>
    </div>
    <div class="positionWrapper">
      <div class="positionItem" v-for="(item,index) in positionList" :key="index" @click="linkToDetail(item.id)">
        <div class="itemInfo leftInfo">
          <h3>{{item.name}}</h3>
          <p>{{item.workPlace}}/{{item.educationRequirements}}</p>
        </div>
        <div class="itemInfo rightInfo">
          <span>{{item.salaryRange}}</span>
        </div>
      </div>
    </div>  
  </div>
</template>
<script>
import {getPositionList} from '../../services'
export default {
  data() {
    return {
      searchValue: '',
      positionList:[]
    }
  },
   beforeRouteEnter(to, from, next) {
    // react to route changes...
    // don't forget to call next()
    next(vm=>{
      console.log(to,from)
      console.log('this',vm.$route.params)
      document.title = vm.$route.params.id ? '校园招聘' : '社会招聘'
    })
    
    // this.$route
    // console.log('params',this.$route.params)
    // 
    // next()
  },
  mounted() {
    getPositionList().then(d=>{
      console.log('职位列表数据',d.data)
      this.positionList = d.data
    })
  },
  methods: {
    linkToDetail(id){
      this.$router.push({name: 'positionDetail',params: {id:id}})
    }
  },
}
</script>
<style scoped lang="less">
  
 .search{
    background-color:#fff;
    /* padding: 5px; */
 }
 .van-search__content{
   background-color: #F2F2F2;
 }

</style>